import {reqGetSearchInfo} from "@/api/index"

// starch仓库
const state = {
  searchList:{}
};
const mutations = {
  GETSEARCHLIST(state,searchList){
    state.searchList = searchList
  }
};
const actions = {
  async getSearchList({commit},params={}){
    // params形参是当用户派发action的时候,第二个参数传递过来的,至少是一个空对象
    let result = await reqGetSearchInfo(params)
    if(result.code == 200){
      commit("GETSEARCHLIST",result.data)
    }
  }
};
//简化数据 计算属性
const getters = {
  //当前search仓库的state数据
  goodsList(state){
    return state.searchList.goodsList || [];
  },
  trademarkList(state){
    return state.searchList.trademarkList || [];
  },
  attrsList(state){
    return state.searchList.attrsList || [];
  }
};

export default {
  state,
  mutations,
  actions,
  getters
}